package testHutools.testReflectUtils;

import cn.hutool.core.util.ReflectUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @version 1.0.0
 * Created by cyd on 2022-09-09 17:30:50
 * @ClassName : hutools.reflectUtils.ReflectDemo
 * @Description : 类描述
 */
public class ReflectDemo {
    @Test
    public void test() {
        // 获得返回的结果
        List<ResultEntity> resultEntityList = ReflectDemo.initResultEntityList();
        Object object = resultEntityList.get(0);

        Long productInfoId = (Long) ReflectUtil.getFieldValue(object, "productInfoId");
        System.out.println(productInfoId);

    }

    private static List<ResultEntity> initResultEntityList() {

        ArrayList<ResultEntity> list = new ArrayList<>();
        ResultEntity resultEntity01 = new ResultEntity(101L, 201L);
        ResultEntity resultEntity02 = new ResultEntity(102L, 202L);
        list.add(resultEntity01);
        list.add(resultEntity02);
        return list;
    }

}


@Data
@AllArgsConstructor
@NoArgsConstructor
class ResultEntity {
    private Long productInfoId;
    private Long deviceInfoId;
}
